package com.dmw.controller;

import com.dmw.dto.Dto;
import com.dmw.service.SearchConsumerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping(value = "search/api")
public class SearchController  {

    @Autowired
    private SearchConsumerService searchConsumerService;

    /**
     * 商品列表页API 4-3 根据城市、一级分类、二级分、时间、排序字段查询商品信息
     * @param map
     * @return
     */
    @PostMapping("/p/list/queryItemList")
    @ResponseBody
    public Dto queryItemList(@RequestBody Map<String,Object> map){
        System.out.println(">>>商品列表页API 4-3 根据城市、一级分类、二级分、时间、排序字段查询商品信息");

        if(map.get("itemTypeId1")==null)
            map.put("itemTypeId1",0);
        if(map.get("itemTypeId2")==null)
            map.put("itemTypeId2",0);
        if(map.get("areaId")==null)
            map.put("areaId",0);
        if(map.get("startTime").equals(""))
            map.put("startTime",null);
        if(map.get("endTime").equals(""))
            map.put("endTime",null);
        System.out.println(map.get("itemTypeId1"));
        System.out.println(map.get("itemTypeId2"));
        System.out.println(map.get("areaId"));
        System.out.println(map.get("startTime"));
        System.out.println(map.get("endTime"));
        System.out.println(map.get("sort"));
        System.out.println(map.get("keyword"));
        return searchConsumerService.queryItemList(map);
    }
}
